	function showPopup(pagina, titulo, width, height){
	  window.open(pagina, titulo, "width=" + width + ", height=" + height + ", top=" + ((screen.height-height)/2) + ", left=" + ((screen.width-width)/2) + ", scrollbars = NO, resizable = NO, location = NO, status = NO, toolbar = NO, menubar = NO");
	} 

	function numeric() {
		if((window.event.keyCode >=48 && window.event.keyCode <=57)){
			return true;
		}else{
			return false;
		}
	}   
		
	function seleccionaModulos(coleccion) {

		var modulos = document.getElementsByName(coleccion); 
		for(var i=0;i<modulos.length;i++){
			modulos[i].checked = "checked";
		}
		
		return true;
	}   	
	
    function limpiaDiv(divName){
	     var div = document.getElementById(divName);
		 while (div.childNodes[0]) {
		    div.removeChild(div.childNodes[0]);
 		 }    
    }
    
    function cambiaCursor(sw){
    	if(sw == 0){
	    	document.body.style.cursor = "url(\"../img/cursor.ani\")";
    	}else if(sw == 1){
	    	document.body.style.cursor="wait";	    	
    	}else if(sw == 2){
	    	document.body.style.cursor="hand";	    	
    	}
    }
    
    function setBarWaitDiv(sw){

   		var barWaitDiv = document.getElementById("barWaitDiv"); 
   				
    	if(sw == 0){
	    	barWaitDiv.style.visibility = "hidden";
    	}else if(sw == 1){
	    	barWaitDiv.style.visibility = "visible";	    	
    	}
    }        
    
    function showLoading(sw){
    	if(sw == 0){
	    	var div = document.getElementById("loading");
	    	document.body.removeChild(div);
    	}else if(sw == 1){
	    	var div = createLoading();
    	}
    }
    
    function createLoading(){
	    var div = document.createElement("div");
	    var divAnim = document.createElement("div");
	    var fWidth = 300;
	    var fHeight = 200
	
   		divAnim.setAttribute('id', 'loadingAnim');
   		divAnim.style.position = 'absolute';
		divAnim.style.top = document.body.scrollTop + ((document.body.clientHeight - fHeight) / 2);
		divAnim.style.left = (document.body.scrollWidth - fWidth) / 2 ;
		divAnim.innerHTML = getFlashString("swf/Loading.swf" , fWidth, fHeight);

		div.setAttribute('id', 'loading');
		div.style.background = '000000';
		div.style.position = 'absolute';
		div.style.top = 0;
		div.style.left = 0;
		div.style.width = document.body.scrollWidth;
		div.style.height = document.body.scrollHeight;
		div.onmousemove = function(){divAnim.style.top = document.body.scrollTop + ((document.body.clientHeight - fHeight) / 2);}		
		div.onmousewheel = function(){divAnim.style.top = document.body.scrollTop + ((document.body.clientHeight - fHeight) / 2);}
	    div.appendChild(divAnim);
	    
	    document.body.appendChild(div);

		setOpacity(div, 30);
    	
		return div;
    }
    
	function setOpacity(div, value) {
		div.style.opacity = value/100;
		div.style.filter = "alpha(opacity='" + value + "')";
	}	
	    
	function imprimeFlash(divName, swf , width, height){
	 var div = document.getElementById(divName);
		div.innerHTML = getFlashString(swf , width, height);
	}
	
	function getFlashString(swf , width, height){
		var flash = 
		"<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"" + width + "\" height=\"" + height + "\">" +
			"<param name=\"movie\" value=\"" + swf + "\" />" +
			"<param name=\"quality\" value=\"high\" />" +
			"<param name=\"wmode\" value=\"transparent\" />" +
			"<param name='scale' value='noScale' />" +
			"<embed src=\"" + swf + "\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\"" + width + "\" height=\"" + height + "\" />" +
		"</object>";
		
		return flash;
	}

	function reseteaCombo(combo){
		limpiaCombo(combo);
		combo.options[0] = new Option("____________SELECCIONA____________",-1);
	}    
	
	function resizeHeader(sw){
		var step = 1;
		var pause = 40;
		var headerHeight = 130;
		var headerHeightSmall = 95;
		var thisHeight = parseFloat(parent.content.rows.split(",")[0]);
		if(sw == 0){
	  		increaseHeader(thisHeight, headerHeight, step, pause);		
		}else if (sw == 1){
  			reduceHeader(thisHeight, headerHeightSmall, step, pause);
		}
	}
	
	function reduceHeader(thisHeight, headerHeightSmall, step, pause){
		parent.content.rows = thisHeight + ",*,30";
   		thisHeight = thisHeight - step;
   		if(thisHeight > headerHeightSmall){
			setTimeout("reduceHeader(" + thisHeight + "," + headerHeightSmall + "," + step + "," + pause + ")", pause);			
   		}	
	}
	
	function increaseHeader(thisHeight, headerHeight, step, pause){
		parent.content.rows = thisHeight + ",*,30";
   		thisHeight = thisHeight + step;
   		
   		if(thisHeight < headerHeight){
			setTimeout("increaseHeader(" + thisHeight + "," + headerHeight + "," + step + "," + pause + ")", pause);			
   		}		
	}	
	
	function imprimeBoton(divName, texto, link, objetivo){
		imprimeFlash(divName, "swf/boton.swf?comando=" + texto + "&link=" + link + "&objetivo=" + objetivo, 105, 30);	
	}		

	function deshabilitaDiv(divName, status){
		var div = document.getElementById(divName);
		div.disabled = status;
	}
	

function llenaFechasDefault(swExactitud, divName, nomFec1, idFec1, nomFec2, idFec2, swBoton){
	var formatter = new SimpleDate();
	var msegDia = 1000*60*60*24;
	var fec1 = document.getElementById(idFec1);
	var fec2 = document.getElementById(idFec2);
  
	switch(swBoton){
		case 1:
			fec1.value = formatter.toFormattedString("~d/~k/~Y");
			fec2.value = formatter.toFormattedString("~d/~k/~Y");
			break;
		case 2:
			var fechaFin = new Date();
			var fechaIni = fechaFin - (msegDia * 6);
			fec2.value = formatter.toFormattedString("~d/~k/~Y");
			formatter = new SimpleDate(fechaIni);
    		fec1.value = formatter.toFormattedString("~d/~k/~Y");
			break;
		case 3:
			fec2.value = formatter.toFormattedString("~d/~k/~Y");
			fec1.value = "01/" + fec2.value.substring(3,5) + "/" + fec2.value.substring(6,10);
			break;
		case 4:
			fec2.value = formatter.toFormattedString("~d/~k/~Y");
    		fec1.value = "01/01/" + fec2.value.substring(6,10);
			break;         
  	}
}

function getRequestParam( paramName )
{
    var regexS = "[\\?&]" + paramName + "=([^&#]*)";
    var regex = new RegExp( regexS );
    var results = regex.exec( window.location.href );
   
    if( results == null )
	return "";
    else
	return results[1];
}